package cn.jhc.Adapter;


import cn.jhc.utils.Strings;

import com.example.shilehui.EnlistActivity;
import com.example.shilehui.R;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;

public class WorkerListViewAdapter extends BaseAdapter {

	Context context;
	private LayoutInflater mInflater;
	TextView worker_horizontal_listview_item_text;
	String addToPaidVolunteer;
	String addToNoPaidVolunteer;
	String[] recruiting_worker_listview=new String[2];
	
	
	public WorkerListViewAdapter(Context context){
		this.context=context;
		mInflater = (LayoutInflater) context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
		addToPaidVolunteer=context.getResources().getString(R.string.enlist_add_to_paid_volunteer);
		addToNoPaidVolunteer=context.getResources().getString(R.string.enlist_add_to_no_paid_volunteer);
		recruiting_worker_listview[0]=addToPaidVolunteer;
		recruiting_worker_listview[1]=addToNoPaidVolunteer;
	
	}
	@Override
	public int getCount() {
		return recruiting_worker_listview.length;
	}
	DataWrapper dataWrapper;
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			convertView = mInflater.inflate(R.layout.recruiting_worker_listview_item, null);
			worker_horizontal_listview_item_text=(TextView) convertView.findViewById(R.id.worker_horizontal_listview_item_text);
			
			dataWrapper=new DataWrapper(worker_horizontal_listview_item_text);
			
			convertView.setTag(dataWrapper);
			
		}else{
			dataWrapper=(DataWrapper) convertView.getTag();
		}
		dataWrapper.worker_horizontal_listview_item_text.setText(recruiting_worker_listview[position]);
		
		
		dataWrapper.worker_horizontal_listview_item_text.setOnClickListener(new onWorkItemClickListener(position));
		
		
		return convertView;
	}

	
	
	
	
	public final class DataWrapper{
		
		private TextView worker_horizontal_listview_item_text;

		public DataWrapper(TextView worker_horizontal_listview_item_text) {
			this.worker_horizontal_listview_item_text = worker_horizontal_listview_item_text;
		} 
	}
	
	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}
	
	
	
	private class onWorkItemClickListener implements OnClickListener{
		
		private int position;
		
		public onWorkItemClickListener(int position){
			
			this.position=position;
			
		}

		@Override
		public void onClick(View v) {
			
			Intent intent=new Intent(context, EnlistActivity.class);
			intent.putExtra(Strings.ENLIST_TITLE,recruiting_worker_listview[position]);
			context.startActivity(intent);
			
		}
		
	}
	
	
	
	
	
}
